{extends file="../acp.html"}

{block name="title"}{$head_title}{/block}
{block name="content"}
<form id="J_FormNotice" action="/AcpIncubator/add_incubator" method="post">
    <div class="formitems inline">
        <label class="fi-name"><span class="colorRed">*</span>孵化器名：</label>
        <div class="form-controls">
            <input type="text" placeholder="" class="xlarge" name="incubator_name" id="incubator_name">
            <span class="fi-help-text hide"></span>
        </div>
    </div>
    <!--<div class="formitems inline">
        <label class="fi-name"><span class="colorRed">*</span>孵化器类型：</label>
        <div class="form-controls">
            <select name="incubator_type" id="incubator_type">
                <option value="">&#45;&#45;请选择&#45;&#45;</option>
                <option value="1">园区</option>
                <option value="2">众创空间</option>
            </select>
            <span class="fi-help-text hide"></span>
        </div>
    </div>-->
    <div class="formitems inline">
        <label class="fi-name">孵化器类型：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" name="incubator_type" value="1" />园区</label>
                <label><input type="radio" name="incubator_type" value="2" />众创空间</label>
            </div>
        </div>
    </div>
    <div class="formitems inline">
        <label class="fi-name">园区类型：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" name="park_type" value="1" />银江自有</label>
                <label><input type="radio" name="park_type" value="2" />其他园区</label>
            </div>
        </div>
    </div>
    <!--<div class="formitems inline">
        <label class="fi-name"><span class="colorRed">*</span>园区类型：</label>
        <div class="form-controls">
            <select name="park_type" id="park_type">
                <option value="">&#45;&#45;请选择&#45;&#45;</option>
                <option value="1">银江自有园区</option>
                <option value="2">其他园区</option>
            </select>
            <span class="fi-help-text hide"></span>
        </div>
    </div>-->
    <div class="formitems inline">
        <label class="fi-name">是否首页显示：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" name="is_index" value="1" {if $service_type_info.isuse == 1}checked="checked"{/if} />是</label>
                <label><input type="radio" name="is_index" value="0" {if $service_type_info.isuse == 0}checked="checked"{/if} />否</label>
            </div>
        </div>
    </div>
    <div class="formitems inline">
        <label class="fi-name">排序号：</label>
        <div class="form-controls">
            <input type="text" placeholder="" name="sort" id="sort">
        </div>
    </div>
    <div class="formitems inline">
        <label class="fi-name"><span class="colorRed">*</span>配套设备：</label>
        <div class="form-controls">
            {foreach from = $equipment_list item =equipment}
            <input type="checkbox" class="checkbox" value="{$equipment.site_deploy_id}" name="equipment[]">{$equipment.site_deploy_name}
            {/foreach}
            <span class="fi-help-text hide"></span>
        </div>

    </div>
    <div class="formitems inline">
        <label class="fi-name">电话：</label>
        <div class="form-controls">
            <input type="text" placeholder="" name="mobile" id="mobile">
        </div>
    </div>
   <!-- <div class="formitems inline">
        <label class="fi-name">来源：</label>
        <div class="form-controls">
            <input type="text" placeholder="" name="notice_source" id="notice_source">
        </div>
    </div>-->
    <div class="formitems inline">
        <label class="fi-name"><span class="colorRed">*</span>请选择省市：</label>
        <div class="form-controls">
            省：<select name="province" id="province" style="width: 120px">
                <option value="">-请选择-</option>
                {foreach from=$province_list item=province}
                <option value="{$province.province_id}">{$province.province_name}</option>
                {/foreach}
                </select>
            市：<select name="city" id="city" style="width: 120px">
            <option value="">-请选择-</option>
            {foreach from=$city_list item=city}
            <option value="{$city.city_id}">{$city.city_name}</option>
            {/foreach}
        </select>

            <span class="fi-help-text hide"></span>
        </div>
    </div>
    <div class="formitems inline">
        <label class="fi-name">地址：</label>
        <div class="form-controls">
            <input type="text" placeholder=""  name="address" id="address">
        </div>
    </div>
    <!--<div class="formitems inline">
        <label class="fi-name">园区封面图：</label>
        <div class="form-controls">
            <ul class="fi-imgslist">
                <li class="fi-imgslist-item pic hide">
                    <div class="pic-wrap">
                        <img id="J_Preview" class="pic-preview" />
                    </div>
                    <input type="hidden" name="img_url" data-id="" id="J_ImgUrl" />
                    <a href="javascript:;" class="del" id="J_Del" title="删除这张图"><i class="gicon-remove"></i></a>
                    <img src="__IMAGES__/popup-loading.gif" id="J_AjaxLoading" class="pic-loading" style="width: 32px; height: 32px;" />
                    <div class="pic-mask" id="J_Mask"></div>
                </li>
                <li class="fi-imgslist-item">
                    <a href="javascript:;" class="add" title="上传一张新的图片" id="J_Uploader">+</a>
                </li>
            </ul>
            <span class="fi-help-text">园区的缩略图，暂时只支持上传单张2M以内JPEG,PNG,GIF格式图片</span>
        </div>
    </div>-->
    {upload_image_widget($pic_data)}
    <div class="formitems inline">
        <label class="fi-name">请选择地址：</label>
    <div class="map_container" id="map_container" style="width:700px;height:400px;"></div><br>
    </div>
    <div class="formitems inline">
        <label class="fi-name">搜索：</label>
        <div class="form-controls">
            <input type="text" placeholder="" class="xlarge" name="suggestId" id="suggestId" value="">
            <div id="searchResultPanel" class="xlarge" style="border:1px solid #C0C0C0;height:auto; display:none;"></div>
            <span class="fi-help-text hide"></span>
        </div>
    </div>
    <div class="formitems inline">
        <label class="fi-name"><span class="colorRed">*</span>园区中心点经度：</label>
        <div class="form-controls">
            <input type="text" placeholder="" class="xlarge" name="center_lng" id="center_lng" value="">
            <span class="fi-help-text hide"></span>
        </div>
    </div>
    <div class="formitems inline">
        <label class="fi-name"><span class="colorRed">*</span>园区中心点纬度：</label>
        <div class="form-controls">
            <input type="text" placeholder="" class="xlarge" name="center_lat" id="center_lat" value="">
            <span class="fi-help-text hide"></span>
        </div>
    </div>
    <div class="formitems inline">
        <label class="fi-name"><!-- <span class="colorRed">*</span> -->简介：</label>
        <div class="form-controls">
            <textarea name="contents" id="contents" class="large" name="contents">{$contents}</textarea>
            <span class="fi-help-text error"></span>
        </div>
    </div>
    <input type="hidden" name="opt" value="add">
    <div class="formitems inline">
        <label class="fi-name"></label>
        <div class="form-controls">
            <input type="hidden" name="act" value="submit" />
            <button type="submit" class="btn btn-blue"><i class="gicon-check white"></i>保存</button>
        </div>
    </div>
</form>
{/block}

{block name="js"}
<!-- 编辑器 -->
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=BQLHGlffjbXC30bFDcpIQkHIkaxKBBe6"></script>
<!--<script src="__KD__/kindeditor.js?version={$version}" > </script>
<script src="__ACPJS__/AcpItem/add_item_step3.js?version={$version}"></script>
<script charset="utf-8" src="__KD__/kindeditor.js?version={$version}" > </script>-->
<script charset="utf-8" src="__KD__/lang/zh_CN.js?version={$version}" > </script>
<script type="text/javascript" src="__JS__/jquery/ajaxupload.3.5.js?version={$version}"></script>
<script type="text/javascript" src="__ACPJS__/AcpNotice/notice_save.js?version={$version}"></script>
<script>
    var lat = '{$school_info.center_lat}' || '28.1255940';
    var lng = '{$school_info.center_lng}' || '120.9820840';
    var map;
    </script>
<!--<script type="text/javascript" src="__JS__/jquery/jquery.min.js"></script>-->
{literal}
<script>
    $('#province').change(function () {
        var province_id = $("#province").find('option:selected').val();
        console.log(province_id);
        $.ajax({
            type:'post',
            url: '/AcpIncubator/getcity',
            data: {province_id: province_id},
            dataType:'json',
            success: function(data){
                //console.log(data);
                var len =data.length;
                var i=0;
                var html='';
                for(i=0;i<len;i++){
                    html+= ' <option value="'+data[i].city_id +'">'+data[i].city_name+'</option>';
                }
                $("#city").html(html);
            }
        });
    });

    map = new BMap.Map("map_container");
    map.addControl(new BMap.NavigationControl()); //初始化地图控件
    map.addControl(new BMap.ScaleControl());
    map.addControl(new BMap.OverviewMapControl());
    //MapTypeControl：地图类型控件，默认位于地图右上方。
    map.addControl(new BMap.MapTypeControl());

    map.setDefaultCursor("url('bird.cur')");  //设置地图默认的鼠标指针样式
    map.enableScrollWheelZoom();        //启用滚轮放大缩小，默认禁用。

    //console.log("lng:"+lng+",lat:"+lat);
    var point = new BMap.Point(lng, lat);
    map.centerAndZoom(point,14);         //初始化地图中心点

    var marker = new BMap.Marker(point); //初始化地图标记
    var gc = new BMap.Geocoder();//地址解析类
    marker.enableDragging();             //标记开启拖拽
    map.addOverlay(marker);              //将标记添加到地图中
    marker.setAnimation(BMAP_ANIMATION_BOUNCE);
    marker.addEventListener("dragend",dragend);
    //添加标记拖拽监听
    /*marker.addEventListener("dragend", function(e){
     //获取地址信息
     //经度
     window.parent.document.getElementById("center_lng").value=e.point.lng;
     //维度
     window.parent.document.getElementById("center_lat").value=e.point.lat;
     gc.getLocation(e.point, function(rs){
     showLocationInfo(e.point, rs);
     });
     });*/
    function dragend(e){
        window.parent.document.getElementById("center_lng").value=e.point.lng;
        //维度
        window.parent.document.getElementById("center_lat").value=e.point.lat;
        gc.getLocation(e.point, function(rs){
            showLocationInfo(e.point, rs);
        });
    }

    function G(id) {
        return document.getElementById(id);
    }
    var ac = new BMap.Autocomplete(    //建立一个自动完成的对象
            {"input" : "suggestId"
                ,"location" : map
            });

    ac.addEventListener("onhighlight", function(e) {  //鼠标放在下拉列表上的事件
        var str = "";
        var _value = e.fromitem.value;
        var value = "";
        if (e.fromitem.index > -1) {
            value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
        }
        str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;

        value = "";
        if (e.toitem.index > -1) {
            _value = e.toitem.value;
            value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
        }
        str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
        G("searchResultPanel").innerHTML = str;
    });

    var myValue;
    ac.addEventListener("onconfirm", function(e) {    //鼠标点击下拉列表后的事件
        var _value = e.item.value;
        myValue = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
        G("searchResultPanel").innerHTML ="onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;

        setPlace();
    });

    function setPlace(){
        map.clearOverlays();    //清除地图上所有覆盖物
        function myFun(){
            var pp = local.getResults().getPoi(0).point;    //获取第一个智能搜索的结果
            map.centerAndZoom(pp, 18);
            marker = new BMap.Marker(pp);
            marker.enableDragging();
            map.addOverlay(marker);    //添加标注
            marker.setAnimation(BMAP_ANIMATION_BOUNCE);
            marker.addEventListener("dragend",dragend);
        }
        var local = new BMap.LocalSearch(map, { //智能搜索
            onSearchComplete: myFun
        });
        local.search(myValue);
    }
</script>
{/literal}
<!--<script type="text/javascript" src="__JS__/jquery/jquery.min.js"></script>-->
{/block}

{block name="css"}
<link rel="stylesheet" href="__KD__/themes/default/default.css" />
<link rel="stylesheet" href="/Public/Css/acp/AcpNotice/add_notice.css"  type="text/css"/>
{/block}


